package com.light.gulimall.search.controller;

import com.light.gulimall.search.dto.SearchDTO;
import com.light.gulimall.search.service.SearchService;
import com.light.gulimall.search.vo.SearchVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class SearchController {

    @Autowired
    private SearchService searchService;

    /**
     * http://localhost:99/list.html?搜索条件
     * @return
     */
    @GetMapping("/list.html")
    public String getList(SearchDTO searchDTO, Model model){
        SearchVO result = searchService.searchForCondition(searchDTO);

        model.addAttribute("result", result);
        return "list";
    }
}
